package com.example.concurrent.chapter03;

import java.util.concurrent.TimeUnit;

import static java.lang.Thread.currentThread;

/**
 * @author Create By Liuqz
 * @date 2018/11/20 10:26
 */
public class ThreadInterrupt {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            try {
                TimeUnit.MINUTES.sleep(1);
            } catch (InterruptedException e) {
                System.out.println("Oh, I am be interrupted.");
            }
        });

        thread.start();

        TimeUnit.MILLISECONDS.sleep(2);
        thread.interrupt();
    }
}
